{include file="./layout/header.html" /}
<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:left" onClick="javaScript:history.go(-1)" title="返回">
        <i class="layui-icon" style="line-height:30px">&#xe65c;</i></a>

    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body" >

    <form class="layui-form" id="intr">

        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input   type="hidden" id="sid" name="sid" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="" value='{$sid}'>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="number" class="layui-form-label">
                <span class="x-red">*</span>论文编号
            </label>
            <div class="layui-input-inline">
                <input   type="text" id="number" name="number" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="" value='{$intr->number}'>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="presentation_preference" class="layui-form-label">
                <span class="x-red">*</span>状态
            </label>
            <div class="layui-input-inline" style="line-height: 40px;">
                <span id="presentation_preference"  class="layui-btn layui-btn-normal layui-btn-mini">{$intr->status_name}</span>
                <!--<input   type="text" id="presentation_preference" name="presentation_preference" required="" lay-verify="required"-->
                         <!--autocomplete="off" class="layui-input" placeholder="" value="{$intr->status_name}">-->
            </div>
        </div>

        <div class="layui-form-item">
            <label for="" class="layui-form-label">
                <span class="x-red">*</span>作者
            </label>
            {foreach $intr->authors as $key => $vo}

            <table class="layui-table" style="width: 70%;">
                <thead>
                <tr>
                    <th>顺序</th>
                    <th>first_name</th>
                    <th>midden_name</th>
                    <th>last_name</th>
                    <th>邮箱</th>
                    <th>头衔</th>
                    <th>国家</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th><input  class="auth" style="border: none;" type="text" value="{$key}"></th>
                    <th><input style="border: none;" name="authors[first_name]" class="auth" type="text" value="{$vo->first_name}"></th>
                    <th><input style="border: none;" name="authors[middle_name]" class="auth" type="text" value="{$vo->middle_name}"></th>
                    <th><input style="border: none;" name="authors[last_name]" class="auth" type="text" value="{$vo->last_name}"></th>
                    <th><input style="border: none;" name="authors[email]" class="auth" type="text" value="{$vo->email}"></th>
                    <th>
                        <div class="layui-input-block" style="margin-left:0px;width: 80px;">

                            <select id="authors[title]" name="authors[title]" lay-verify="">
                                <option value="{$vo->title}">{$vo->title}</option>
                                {foreach $data.title as $key => $v}
                                <option value="{$key}">{$v}</option>
                                {/foreach}
                            </select>
                        </div>
                    </th>
                    <th>
                        <div class="layui-input-block" style="margin-left:0px;width: 80px;">

                            <select id="authors[country]" name="authors[country]" lay-verify="">
                                <option value="{$vo->country}">{$vo->country}</option>
                                {foreach $data.countries as $key => $v}
                                <option value="{$key}">{$v}</option>
                                {/foreach}
                            </select>
                        </div>
                    </th>
                </tr>
                </tbody>
            </table>
            {/foreach}

        </div>


        {present name="$intr->translations[1]"}
        {foreach $lang.hy as $key => $vo}
        {if condition="$vo.lan eq $intr->translations[$key]->locale"}
        <div class="layui-form-item">
            <label for="['{$vo.lan}']['title']" class="layui-form-label">
                <span class="x-red">*</span>{$vo.title}
            </label>
            <div class="layui-input-inline">
                <input   type="text" id="['{$vo.lan}']['title']" name="translations[{$vo.lan}][title]" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="" value="{$intr->translations[$key]->title}">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="['{$vo.lan}']['remark']" class="layui-form-label">
                <span class="x-red">*</span>{$vo.content}
            </label>
            <div class="layui-input-block">
                <textarea style="padding:0px" placeholder="请输入内容" id="['{$vo.lan}']['remark']" name="translations[{$vo.lan}][remark]" class="layui-textarea">{$intr->translations[$key]->remark}</textarea>
            </div>
        </div>
        {if condition="$vo.lan eq 'en'"}
        <!-- 实例化编辑器 -->
        <script type="text/javascript">
            var ue = UE.getEditor("['en']['remark']");
        </script>
        {else/}
        <script type="text/javascript">
            var ue = UE.getEditor("['zh-CN']['remark']");
        </script>
        {/if}
        {else/}
        <div class="layui-form-item">
            <label for="['{$vo.lan}']['title']" class="layui-form-label">
                <span class="x-red">*</span>{$vo.title}
            </label>
            <div class="layui-input-inline">
                <input   type="text" id="['{$vo.lan}']['title']" name="translations[{$vo.lan}][title]" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="" value="{$intr->translations[$key+1]->title}">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="['{$vo.lan}']['remark']" class="layui-form-label">
                <span class="x-red">*</span>{$vo.content}
            </label>
            <div class="layui-input-block">
                <textarea style="padding:0px" placeholder="请输入内容" id="['{$vo.lan}']['remark']" name="translations[{$vo.lan}][remark]" class="layui-textarea">{$intr->translations[$key+1]->remark}</textarea>
            </div>
        </div>
        {if condition="$vo.lan eq 'en'"}
        <!-- 实例化编辑器 -->
        <script type="text/javascript">
            var ue = UE.getEditor("['en']['remark']");
        </script>
        {else/}
        <script type="text/javascript">
            var ue = UE.getEditor("['zh-CN']['remark']");
        </script>
        {/if}
        {/if}
        {/foreach}
        {/present}

        {notpresent name="$intr->translations[1]"}
        {foreach $lang.hy as $key => $vo}

        <div class="layui-form-item">
            <label for="['{$vo.lan}']['title']" class="layui-form-label">
                <span class="x-red">*</span>{$vo.title}
            </label>
            <div class="layui-input-inline">
                {foreach $lang.hy as $key => $v}
                {present name="$intr->translations[$key]->title"}
                {if condition="$vo.lan eq $intr->translations[$key]->locale"}
                <input   type="text" id="['{$vo.lan}']['title']" name="translations[{$vo.lan}][title]" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="" value="{$intr->translations[$key]->title}">
                {else/}
                <input   type="text" id="['{$vo.lan}']['title']" name="translations[{$vo.lan}][title]" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="" value="">
                {/if}
                {/present}
                {/foreach}

            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="['{$vo.lan}']['remark']" class="layui-form-label">
                <span class="x-red">*</span>{$vo.content}
            </label>
            <div class="layui-input-block">
                {foreach $lang.hy as $key => $v}
                {present name="$intr->translations[$key]->remark"}
                {if condition="$vo.lan eq $intr->translations[$key]->locale"}
                <textarea style="padding:0px" placeholder="请输入内容" id="['{$vo.lan}']['remark']" name="translations[{$vo.lan}][remark]" class="layui-textarea">{$intr->translations[$key]->remark}</textarea>
                {else/}
                <textarea style="padding:0px" placeholder="请输入内容" id="['{$vo.lan}']['remark']" name="translations[{$vo.lan}][remark]" class="layui-textarea"></textarea>
                {/if}

                {/present}
                {/foreach}
            </div>
        </div>
        {if condition="$vo.lan eq 'en'"}
        <!-- 实例化编辑器 -->
        <script type="text/javascript">
            var ue = UE.getEditor("['en']['remark']");
        </script>
        {else/}
        <script type="text/javascript">
            var ue = UE.getEditor("['zh-CN']['remark']");
        </script>
        {/if}
        {/foreach}
        {/notpresent}

        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input  readonly="readonly" type="hidden" id="uid" name="id" required="" lay-verify="required"
                        autocomplete="off" class="layui-input nowrite" value="{$intr->uid}">
            </div>
        </div>

        <div class="layui-form-item">
            <label  class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                修改
            </button>
        </div>
    </form>
<br><br>

    <!--<span>-->
        <!--论文摘要部分-->
    <!--</span>-->
    <!--<hr class="layui-bg-green">-->
    <!--<div class="layui-form-item">-->
        <!--<label for="" class="layui-form-label">-->
            <!--<span class="x-red">*</span>摘要地址-->
        <!--</label>-->
        <!--<div class="layui-input-inline">-->
            <!--<input   type="text" id="abstract" name="abstract[file_url]" required="" lay-verify="required"-->
                     <!--autocomplete="off" class="layui-input" placeholder="" value="{$intr->abstract->file_url}">-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label for="" class="layui-form-label">-->
            <!--<span class="x-red">*</span>摘要状态-->
        <!--</label>-->
        <!--<div class="layui-input-inline" style="line-height: 40px;">-->
            <!--<span  class="layui-btn layui-btn-normal layui-btn-mini">{$intr->abstract->status_name}</span>-->
            <!--&lt;!&ndash;<input   type="text" id="abstract" name="abstract[file_url]" required="" lay-verify="required"&ndash;&gt;-->
                     <!--&lt;!&ndash;autocomplete="off" class="layui-input" placeholder="" value="{$intr->abstract->status_name}">&ndash;&gt;-->
        <!--</div>-->
    <!--</div>-->

    <!--<div class="layui-form-item">-->
        <!--<label  class="layui-form-label">-->
        <!--</label>-->
        <!--<button  class="layui-btn" lay-filter="" lay-submit="">-->
            <!--点击查看摘要列表-->
        <!--</button>-->
    <!--</div>-->
</div>

<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data){
            var uid = $('#uid').val();
            //发异步，把数据提交给php
            $.ajax({
                dataType : 'json',
                type : 'POST',
                url : '{:url("Conferpaper/update")}',
                async: false,
                data : $('#intr').serialize(),
                success : function(msg){
                    layer.alert(msg.msg, {icon: 6},function () {
                        window.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                },
                error : function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status + "," + textStatus);
                }
            });

            return false;
        });
    });

    layui.use('table', function(){
        var table = layui.table;

        //监听单元格编辑
        table.on('edit(test3)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
        });
    });


</script>
{include file="./layout/footer.html" /}